package io.qaralotte.ncmdump;

import io.qaralotte.ncmdump.dump.NcmDump;
import io.qaralotte.ncmdump.utils.ErrorUtils;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Stream;

public class Main {

    public static void main(String[] args) {
        if (args.length == 0) {
            ErrorUtils.error("No input .ncm File");
        } else {
            for (String arg : args) {
                try (Stream<Path> stream = Files.walk(Path.of(arg))) {
                    stream.forEach(path -> {
                        if (Files.isRegularFile(path)) {
                            System.out.println("文件: " + path);
                            File file = new File(path.toString());
                            NcmDump ncmDump = new NcmDump(file);
                            ncmDump.execute();
                        } else if (Files.isDirectory(path)) {
                            System.out.println("目录: " + path);
                        }
                    });
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }

        }
    }
}
